/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.cax.service.strategy.impl;

import com.comac.ins.cax.service.strategy.ConversionStrategy;
import com.comac.ins.cax.utils.ExecUtils;
import com.comac.ins.cax.utils.FileUtils;

import java.io.File;
import java.io.IOException;

/**
 * @author yk
 * @desc CAD STEP转换OBJ
 * @date 2024-06-18 16:17
 */
public class CadStepToObjConverter implements ConversionStrategy {

    private static final String CONVERT_URL = "/data/cax/dataExchange";

    @Override
    public boolean convert(String inputFilePath) throws IOException, InterruptedException {
        String logUrl = FileUtils.changeFileExtension(inputFilePath, "log");
        String outputFilePath = FileUtils.changeFileExtension(inputFilePath, "obj");
        ExecUtils.exec(CONVERT_URL + " " + inputFilePath + " --export " + outputFilePath, logUrl);
        // 检测文件是否生成，返回boolean
        return new File(outputFilePath).exists();
    }
}
